package com.gzsxy.esjy.eureka.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;


/**
 * 服务下线监听器
 */
@Configuration
public class InstanceCancelListener implements ApplicationListener<EurekaInstanceCanceledEvent> {

    private static final Logger logger  = LoggerFactory.getLogger(InstanceCancelListener.class);


    @Override
    public void onApplicationEvent(EurekaInstanceCanceledEvent event) {
        if (event != null) {
            logger.info("服务：【{}】下线了,服务标识【{}】",event.getAppName(),event.getServerId());
        } else {
            logger.error("服务：【未知】服务下线了");
        }
    }
}
